//
//  ViewController.m
//  倒计时
//
//  Created by MyMac on 15/9/28.
//  Copyright (c) 2015年 tongfang. All rights reserved.
//

#import "ViewController.h"
#import "TimerLabel.h"

@interface ViewController ()

@property(nonatomic,strong)TimerLabel*label;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    TimerLabel*label=[[TimerLabel alloc]initWithFrame:CGRectMake(100, 100, 100, 40)];
    [label setBackgroundColor:[UIColor redColor]];
    self.label=label;
    [self.view addSubview:label];
    

    
    UIButton*start=[[UIButton alloc]initWithFrame:CGRectMake(100,220, 100, 40)];
    start.backgroundColor=[UIColor yellowColor];
    [start addTarget:self action:@selector(start:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:start];
    
    UIButton*end=[[UIButton alloc]initWithFrame:CGRectMake(100, 300, 100, 40)];
    [end setBackgroundColor:[UIColor yellowColor]];
    [end addTarget:self action:@selector(end:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:end];
    
    
    UIButton*btn=[[UIButton alloc]initWithFrame:CGRectMake(100, 400, 100, 40)];
    [btn setBackgroundColor:[UIColor yellowColor]];
    [btn addTarget:self action:@selector(removeView:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)end:(id)sender {
    [self.label endTimer];
    
}
- (void)start:(id)sender {
    
    [self.label startTimer];
    
    
}
- (void)removeView:(id)sender {
    
    [self.label removeFromSuperview];
    self.label=nil;
    //[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
